package com.ruoyi.web.controller.app;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.PaOrder;
import com.ruoyi.system.domain.bo.PxBoxBo;
import com.ruoyi.system.domain.vo.PxBoxVo;
import com.ruoyi.system.service.IUserPxBoxService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName SupplierBoxController
 * @Description 用户拼柜业务
 * @date 2024/7/4 18:17
 * @Version 1.0
 * @Auther: zhangzhenyu
 */
@RestController
@RequestMapping("/user/pxbox")
@Api(tags = "用户拼箱表")
public class UserPxBoxController extends BaseController {

    @Autowired
    private IUserPxBoxService userPxBoxService;


    /**
     * 新增代购订单（purchase agency）
     */
    @ApiOperation(value = "用户提交拼箱订单", notes = "用户提交拼箱订单")
    @Log(title = "供应商提交拼装订单（purchase agency）", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public R add(@Validated @RequestBody PxBoxBo pxBoxBo) {
        pxBoxBo.setUserId(getUserId());
        return R.ok(userPxBoxService.insertPxBox(pxBoxBo));
    }

    @ApiOperation(value = "用户查询拼箱订单列表（purchase agency）", notes = "用户查询拼箱订单列表（purchase agency）")
    @Log(title = "用户查询拼箱订单列表（purchase agency）", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public TableDataInfo<PxBoxVo> list(PxBoxBo pxBoxBo)
    {
        pxBoxBo.setUserId(getUserId());
        return userPxBoxService.selectPxBoxList(pxBoxBo);
    }

    /**
     * 修改拼箱订单（purchase agency）
     */
    @ApiOperation(value = "更新用户拼箱订单详情boxId必传", notes = "更新用户拼箱订单详情boxId必传")
    @Log(title = "更新拼箱订单详情（purchase agency）", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public R edit(@RequestBody PxBoxBo pxBoxBo)
    {
        pxBoxBo.setUserId(getUserId());
        return  userPxBoxService.updatePxBox(pxBoxBo);
    }

    /**
     * 获取拼箱订单的详情详细信息
     */
    @GetMapping(value = "/{boxId}")
    @ApiOperation(value = "获取拼箱订单的详情详细信息", notes = "获取拼箱订单的详情详细信息")
    public R<PxBoxVo> getInfo(@PathVariable("boxId") Long boxId)
    {
        return R.ok(userPxBoxService.selectPxBoxItemById(boxId));
    }




}
